Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fonteditor-core

Package Overview
Dependencies
Maintainers
3
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fonteditor-core

fonts (ttf, woff, eot, svg, otf) parse, write, transform. glyph adjust.

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

fonteditor-core

FontEditor core functions

NPM version Build Status Downloads

Feature

  • sfnt parse
  • read, write, transform fonts (ttf, woff, eot, svg, otf)
  • ttf glyph adjust
  • svg to glyph

Usage

// read font file
var Font = require('fonteditor-core').Font;
var fs = require('fs');
var buffer = fs.readFileSync('font.ttf');

// read font data
var font = Font.create(buffer, {
  type: 'ttf', // support ttf,woff,eot,otf,svg
  subset: [65, 66], // only read `a`, `b` glyf
  hinting: true, // save font hinting
  compound2simple: true, // transform ttf compound glyf to simple
  inflate: null, // inflate function for woff
  combinePath: false, // for svg path
});
var fontObject = font.get();
console.log(Object.keys(fontObject));
/* => [ 'version',
  'numTables',
  'searchRenge',
  'entrySelector',
  'rengeShift',
  'head',
  'maxp',
  'glyf',
  'cmap',
  'name',
  'hhea',
  'post',
  'OS/2',
  'fpgm',
  'cvt',
  'prep'
]
*/

// write font file
var buffer = font.write({
  type: 'woff', // support ttf,woff,eot,otf,svg
  hinting: true, // save font hinting
  deflate: null, // deflate function for woff
});
// fs.writeFileSync('font.woff', buffer);

// to base64 str
font.toBase64({
  type: 'ttf' // support ttf,woff,eot,svg
});

// optimize glyf
font.optimize()

// compound2simple
font.compound2simple()

// sort glyf
font.sort()

// find glyf
var result = font.find({
  unicode: [65]
});
var result = font.find({
  filter: function (glyf) {
    return glyf.name == 'icon'
  }
});

// merge another font object
font.merge(font1, {
  scale: 1
});

Demo

edp webserver

open http://127.0.0.1:9999/demo

License

MIT © Fonteditor

Keywords

FAQs

Package last updated on 01 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc